<?php

namespace app\common\model\activity;

use think\Model;


class Apply extends Model
{

    

    

    // 表名
    protected $name = 'activity_apply';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'check_text'
    ];
    

    
    public function getCheckList()
    {
        return ['0' => '待审核', '1' => '通过', '2' => '拒绝'];
    }


    public function getCheckTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['check']) ? $data['check'] : '');
        $list = $this->getCheckList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function activityitem()
    {
        return $this->belongsTo('app\common\model\activity\Item', 'activity_item_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function user()
    {
        return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
